<?php

/**
 * Webpage to provide functions to convert raw-latex-tables (exported from R session)
 * into usable latex code (i.e. adding colors or combining columns)
 * 
 * @author voellenk
 */


set_include_path(get_include_path(). PATH_SEPARATOR. 'inc/');
require_once 'inc/globals.secret.php';
function __autoload($class_name) {
  require_once $class_name.'.class.php';
}

session_start();

//print_r($_POST);

$sani = new sanitizer();
if(empty($_POST)) {
  $unsanitized="";
} else {
  if (array_key_exists("clear", $_POST)) {
    $unsanitized= "";
  } else {
    $unsanitized= $_POST['raw_text'];
    if ($_POST['raw_text'] !="") {
      switch ($_POST['tabletype']) {
        case "tableRetMeanSd" : $sani->sanitize_tableRetMeanSd($unsanitized); break;
        case "tableAllGroupsSummary" : $sani->sanitize_tableAllGroupsSummary($unsanitized); break;   
        case "tableAllTopStopLogicPatterns" : $sani->sanitize_tableAllTopStopLogicPatterns($unsanitized); break; 
        case "tableNextCandleGroupOverview" : $sani->sanitize_tableNextCandleGroupOverview($unsanitized); break; 
        case "tableAppliedStrategy" :  $sani->sanitize_tableAppliedStrategy($unsanitized); break; 
        case "tableStockStatus" : $sani->sanitize_tableStockStatus($unsanitized); break;
      }
    }
  }
}

$page = new symsearchpage("va_stratlab latex table modifier");

echo $page->htmlhead();
echo $page->htmlbodytag();
echo $page->linkToHomepage();
echo "<h1>modify/sanitize latex tables created from R's xtable function</h1>\n";
echo "<form name='latex_table_modifier' method='post'>\n";
echo "<select name='tabletype' size='1'>";
echo "<option>tableRetMeanSd</option>\n";
echo "<option>tableAllGroupsSummary</option>\n";
echo "<option>tableAllTopStopLogicPatterns</option>\n";
echo "<option>tableNextCandleGroupOverview</option>\n";
echo "<option>tableAppliedStrategy</option>\n";
echo "<option>tableStockStatus</option>\n";
echo "</select>\n";
echo "<input type='submit' value='sanitize'>\n";
echo "<input type='submit' name='clear' value='clear'><br />\n";
echo "<textarea name='raw_text' cols='90' rows='15'>$unsanitized</textarea>\n";
echo "</form>\n";

echo "<h2>sanitized text</h2>\n";
echo "<pre>\n";
echo $sani->sanitized;
echo "</pre>\n";

echo $page->htmlend();
?>
